static GPS_PTrack *cur_tx_tracklist_entry;
static char *getposn;
static char *poweroff;
+static char *snlen;
+static char *snwhiteopt;
static
arglist_t garmin_args[] = {
- { "get_posn", &getposn, "Return current position as a waypoint", ARGTYPE_BOOL},
- { "power_off", &poweroff, "Command unit to power itself down", ARGTYPE_BOOL},
+ { "snlen", &snlen, "Length of generated shortnames", ARGTYPE_INT },
+ { "snwhite", &snwhiteopt, "(0/1) Allow whitespace synth. shortnames",
+ ARGTYPE_BOOL},
+ { "get_posn", &getposn, "Return current position as a waypoint",
+ ARGTYPE_BOOL},
+ { "power_off", &poweroff, "Command unit to power itself down",
+ ARGTYPE_BOOL},
{ 0, 0, 0, 0}
};
break;
}
- setshort_length(mkshort_handle, short_length);
+ /*
+ * If the user provided a short_length, override the calculated value.
+ */
+ if (snlen)
+ setshort_length(mkshort_handle, atoi(snlen));
+ else
+ setshort_length(mkshort_handle, short_length);
+
+ if (snwhiteopt)
+ setshort_whitespace_ok(mkshort_handle, atoi(snwhiteopt));
+
setshort_mustupper(mkshort_handle, 1);
}
extern queue waypt_head;
GPS_PWay *way;
extern int32 gps_save_id;
+ int icon;
way = xcalloc(n,sizeof(*way));
waypoint *wpt;
char *ident;
char *src = NULL;
+ char obuf[256];
wpt = (waypoint *) elem;
xfree(ident);
}
way[i]->ident[sizeof(way[i]->ident)-1] = 0;
- if (src && strlen(src)) {
- memcpy(way[i]->cmnt, src, strlen(src));
+
+ if (wpt->gc_data.diff && wpt->gc_data.terr) {
+ snprintf(obuf, sizeof(obuf), "%d/%d %s",
+ wpt->gc_data.diff, wpt->gc_data.terr,
+ src);
+ memcpy(way[i]->cmnt, obuf, strlen(obuf));
+ } else {
+ memcpy(way[i]->cmnt, obuf, strlen(src));
}
way[i]->lon = wpt->longitude;
way[i]->lat = wpt->latitude;
- way[i]->smbl = mps_find_icon_number_from_desc(wpt->icon_descr, PCX);
+
+ if (get_cache_icon(wpt)) {
+ icon = mps_find_icon_number_from_desc(get_cache_icon(wpt), PCX);
+ } else {
+ icon = mps_find_icon_number_from_desc(wpt->icon_descr, PCX);
+ }
+ way[i]->smbl = icon;
if (wpt->altitude != unknown_alt) {
way[i]->alt = wpt->altitude;
}
GPS_PWay ret;
int32 i;
- if(!(ret=(GPS_PWay)malloc(sizeof(GPS_OWay))))
+ if(!(ret=(GPS_PWay)xcalloc(sizeof(GPS_OWay),1)))
{
perror("malloc");
fprintf(stderr,"GPS_Way_New: Insufficient memory");
return NULL;
}
+ /*
+ * It turns out that the Way struct, initialized with zeros (not the
+ * random stuff that we got with malloc, but REALLY initialized with
+ * zeros from the calloc above actually does use C strings and it's
+ * up to the various way_blah_send functions to zero/string pad things
+ * as it goes. So neutralize this.
+ */
+#if 0
+
/*
* Mark all as "unused". These appear in the same order as in the struct.
*/
-#define BLANK(x) memset(x, ' ',sizeof(x))
+#define BLANK(x) memset(x, ' ',sizeof(x))
BLANK(ret->ident);
BLANK(ret->cmnt);
BLANK(ret->wpt_ident);
ret->facility[0] = 0;
ret->addr[0] = 0;
ret->wpt_ident[0] = 0;
+#endif
ret->lat = ret->lon = GPS_FLTMAX;
ret->dst = 0;
}
}
+void
+DiagS(void *buf, size_t sz)
+{
+ unsigned char *cbuf = (unsigned char *) buf;
+
+ while (sz--) {
+ unsigned char c = *cbuf++;
+ GPS_Diag("%c", isalnum(c) ? c : '.');
+ }
+}
+
/* @func GPS_Write_Packet ***********************************************
**
** Forms a complete packet to send
Diag(&packet->chk, 3);
+
+ GPS_Diag(": ");
+ DiagS(packet->data, packet->bytes);
+ DiagS(&packet->chk, 3);
+
if((ret=GPS_Serial_Write(fd,(const void *)&packet->chk,(size_t)3)) == -1)
{
perror("write");